<?php

class MainWindow extends GtkWindow
{
	public $right;
	public $fileNum =0;
	function __construct()
	{
		parent::__construct();
		$this->connect_simple('destroy', array('gtk', 'main_quit'));
        $this->set_title('PHP Development');
        $this->maximize();//最大化
		$this->MainFrame();
		$this->show_all();
	}
	function MainFrame()
	{
		$frame = new GtkVBox(false, 0);
		$this->add($frame);
		$frame->pack_start($this->MainMenu(), false, false, 0);
		$frame->pack_start($this->MainTool(), false, false, 0);
		$frame->pack_start($this->WindowCenter());
		$frame->pack_start($this->WindowStatus(), false, false);
	}
	function MainMenu()
	{
		$menuBar = new GtkMenuBar();
		$menuList = array('文件(_F)'	=>array('新建文件(_N)'=>array('newFile','Ctrl+N'),
										 '-',
										 '打开文件(_O)'	=>'openFile',
										 '关闭文件(_C)'	=>'closeFile',
										 '全部关闭'	=>'closeAll',
										 '-',
										 '保存(_S)'		=>'save',
										 '另存为(_A)'	=>'saveAs',
										 '全部保存(_V)'		=>'saveAll',
										 '-',
										 '最近打开的项目'=>'histoy',
										 '-',
										 '添加FTP'		=>'addFtp',
										 '-',
										 '打印(_P)'		=>'printCode',
										 '-',
										 '退出(_X)'		=>'mainQuit',
										 ),
							'编辑(_E)'	 =>array('剪切(_T)' => '', '复制(_C)' => '', '粘贴(_P)' => '', '-', '全选(_L)' => '', '-', '代码缩进(_I)'=>''), 
							'搜索(_S)'=>array('查找(_F)' => '', '查找替换(_R)' => '', '查找下一个(_N)'=>'', '查找上一个(_P)'=>'', '-', '在文件中查找(_S)'=>''),
							'转到(_G)'	 =>array('转到文件(_F)' => '', '转到文件(_L)' => '', '转到匹配的括号(_M)'=>''),
							'项目(_P)'=>array('新建项目(_N)'=>'', '打开项目(_T)'=>'', '保存项目'=>'', '关闭项目'=>'', '-', '添加到项目(_A)'=>'', '-', '项目属性(_R)'=>''),
							'视图(_V)'   =>array('Show/Hide File Manage'=>''),
							'调试(_D)'  =>array('Show/Hide message'=>''),
							'工具(_T)'   =>array('首选项(_F)'=>''),
							'帮助(_H)'   =>array('About'=>''));
		include_once(ROOT.'function.php');
		$menuBar = CreateMenu($menuBar,$menuList);
		return $menuBar;
	}
	function MainTool()
	{
		$toolBar = new GtkToolBar();
		$toolList = array('newFile' => Gtk::STOCK_NEW, 'openFile'=>Gtk::STOCK_OPEN, 'save'=>Gtk::STOCK_SAVE, '|',
						  'cut'=>Gtk::STOCK_CUT, 'copyWord'=>Gtk::STOCK_COPY, 'paste'=>Gtk::STOCK_PASTE,'undo'=>Gtk::STOCK_UNDO,
						  'redo'=>Gtk::STOCK_REDO, '|', 'find'=>Gtk::STOCK_FIND, 'findAndReplace'=>Gtk::STOCK_FIND_AND_REPLACE, '|',
						  'preferences'=>Gtk::STOCK_PREFERENCES);
		$toolBar = CreateTool($toolBar, $toolList);
		return $toolBar;
	}
	function WindowCenter()
	{
		$center = new GtkHBox();
		$center->pack_start($this->WindowCenterLeft(), false,false, 2);
		$center->pack_start($this->WindowCenterRight());
		return $center;
	}
	function WindowStatus()
	{
		$statusBar= new GtkStatusBar();
		return $statusBar;
	}
	function WindowCenterLeft()
	{
		$left = new GtkNotebook();
		$left ->append_page($this->filesystem(), new GtkLabel('Filesytem'));
		$left ->append_page($this->project(), new GtkLabel('Project'));
		$left ->append_page($this->db(), new GtkLabel('SQL'));
		return $left;
	}
	function WindowCenterRight()
	{
		$this->right = new GtkNotebook();
		$this->right = CreateNewFile($this->right,$this->fileNum);
		return $this->right;
	}
	function filesystem()
	{
		return new GtkTreeView();
	}
	function project()
	{
		return new GtkTreeView();
	}
	function db()
	{
		return new GtkTreeView();
	}
}

?>